// 模拟cookie中有登录信息
// document.cookie = "login=1;"

// 判断是否有登录页login=1
let cookies = document.cookie.split("; ");

let isLogin = false;
for (let i = 0; i < cookies.length; i++) {

    let kv = cookies[i].split("=");

    if (kv[0] === "login" && kv[1] === "1") {
        // 发现登录cookie login=1
        isLogin = true;
        break;
    }
}

// 如果没登录 跳转登录页
if (!isLogin) {
    window.location.href = "./login.html";
} 